package com.zhl.study.getThreadResult;

/**
 * @description join获取线程执行结果
 * @Author: z156940l@outlook.com
 * @className ResultThread
 * @Date: 2024/5/23 10:41
 */
public class ResultThread implements Runnable {
    private static Integer result = null;

    @Override
    public void run() {
        // 模拟一些耗时操作
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        result = calculateResult(); // 线程执行结果
    }

    private static Integer calculateResult() {
        // 模拟计算结果的操作
        return 42;
    }

    public static Integer getResult() {
        return result;
    }
}
